Humans have a remarkable ability to flexibly interact with the environment. A compelling demonstration of this cognitive flexibility is our ability to perform complex, yet previously un-practiced tasks successfully on the first attempt. We refer to this ability as `ad hoc self-programming': `ad hoc' because these new behavioral repertoires are cobbled together on the fly, based on immediate demand, and then discarded when no longer necessary; `self-programming' because the brain has to configure itself appropriately based on task demands and some combination of prior experience and/or instruction. This type of learning differs importantly from trial-and-error learning, in which responses are sculpted incrementally, based on feedback from previous attempts. In comparison to trial-and-error learning, much less is known about ad hoc self- programmed learning, but it clearly represents a fundamental feature of human intelligence. The overall goal of our research proposal is to understand the neurophysiological and computational basis for ad hoc self-programmed behavior. There have been significant barriers to the study of this topic. Among them are the difficulty of studying these processes in animals who require training (which by definition precludes single-trial self- programming), and the lack of access to opportunities with sufficient spatiotemporal resolution to study neuronal processes in humans. The proposed research seeks to address this gap. We leverage critical advances in neuroscience, neurosurgery, engineering, and computational modelling, including: 1) availability of a large-scale recording platform enabling simultaneous recordings of 100+ neurons from the cortical surface; 2) opportunities to record from dorsolateral prefrontal cortex (dlPFC) in human subjects engaged in a custom-designed behavioral task; 3) developments borrowed from the artificial intelligence community to create advanced neural network models of complex cognitive processes. By applying these innovative methodologies, we focus on addressing our overall goal with three Specific Aims. In Aim 1, we determine what information about the structure of a novel, complex, instructed task is represented in human dlPFC neuronal activity. We also determine how and when this information is encoded, in terms of spiking activity, oscillatory activity, or coherence between the two. In Aim 2, we determine the relationship between these neuronal representations and behavior. We investigate how the robustness and timing of the emergence of required neural representations relates to response accuracy and reaction time. In Aim 3, we develop a computational model of ad hoc self-programmed learning. To do so, we borrow from recent insights in the AI world regarding prefrontal network structure, and also apply our developing understanding of neural representations from the previous Aims. We expect that this innovative approach will revolutionize our understanding of this amazing capacity for immediate, configurable learning that characterizes our everyday lives. In doing so, we will develop new strategies to study mechanisms of rapid, flexible cognitive control in general. A better understanding of human cognitive control and its nuanced capacities will naturally translate into an appreciation of deficiencies in these processes, and how they manifest in the form of neuropsychiatric disorders. This appreciation can then lead to the development of rational, targeted therapies.